#include "RaycasterWidget.h"
#include <QPainter>

RaycasterWidget::RaycasterWidget(QWidget *parent, Qt::WFlags flags)
    : QWidget(parent, flags)
{
	ui.setupUi(this);

	//setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	//fixedWidth = 400;
	//fixedHeight = 200;


}

RaycasterWidget::~RaycasterWidget()
{

}

void RaycasterWidget::SetPixel(unsigned int x, unsigned int y, const Pixel& pixel)
{
}

const Pixel& RaycasterWidget::GetPixel(unsigned int x, unsigned int y) const
{
	Pixel p;

	return p;
}

unsigned int RaycasterWidget::GetHeight() const
{
	return height();
}

unsigned int RaycasterWidget::GetWidth() const
{
	return width();
}

void RaycasterWidget::resizeEvent(QResizeEvent *e)
{
	//fixedWidth = e->size().width();
	//fixedHeight = e->size().height();

	//if (fixedHeight == 0)
	//	fixedHeight = 100;


	//fixedWidth = fixedHeight;

	

	//qDebug("Resize = %d, %d", fixedWidth, fixedHeight);

	//resize(fixedWidth, fixedHeight);
}

QSize RaycasterWidget::sizeHint() const
{
	return QSize(100,100);
}

QSize RaycasterWidget::minimumSizeHint() const
{
	return QSize(100, 100);
}

QSize RaycasterWidget::maximumSizeHint() const
{
	return QSize(400, 200);
}

void RaycasterWidget::paintEvent(QPaintEvent *e)
{
	QPainter painter(this);

     painter.setPen(palette().dark().color());
	 painter.setBrush(QBrush(Qt::green));
     painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
}
